package com.fc.v2.service;

import java.util.List;
import java.util.Arrays;

import com.fc.v2.model.auto.DetectionExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.util.StrUtil;
import com.fc.v2.common.base.BaseService;
import com.fc.v2.common.support.ConvertUtil;
import com.fc.v2.mapper.auto.ScaletabMapper;
import com.fc.v2.model.auto.Scaletab;
import com.fc.v2.model.auto.ScaletabExample;
import com.fc.v2.model.custom.Tablepar;
import com.fc.v2.util.SnowflakeIdWorker;
import com.fc.v2.util.StringUtils;

/**
 * 待检测列表 ScaletabService
 * @Title: ScaletabService.java 
 * @Package com.fc.v2.service 
 * @author cjh_自动生成
 * @email ${email}
 * @date 2025-01-30 12:29:49  
 **/
@Service
public class ScaletabService implements BaseService<Scaletab, ScaletabExample>{
	@Autowired
	private ScaletabMapper scaletabMapper;
	
	
	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<Scaletab> list(Tablepar tablepar,Scaletab scaletab){
	        ScaletabExample testExample=new ScaletabExample();
			//搜索
			if(StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
	        	testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
	        }else {//大搜索
	        	testExample.createCriteria().andLikeQuery(scaletab);
	        }
			//表格排序
			//if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
	        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
	        //}else{
	        //	testExample.setOrderByClause("deid ASC");
	        //}
	        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
	        List<Scaletab> list= scaletabMapper.selectByExample(testExample);
	        PageInfo<Scaletab> pageInfo = new PageInfo<Scaletab>(list);
	        return  pageInfo;
	 }

		public Scaletab listtop1(String read2){
			ScaletabExample testExample=new ScaletabExample();
			ScaletabExample.Criteria criteria = testExample.createCriteria();
			criteria.andRead2EqualTo(read2);
			List<Scaletab> list= scaletabMapper.selectByExample(testExample);
			return  list.get(0);
		}
	@Override
	public int deleteByPrimaryKey(String ids) {
		
			List<String> lista=ConvertUtil.toListStrArray(ids);
			ScaletabExample example=new ScaletabExample();
			example.createCriteria().andDeidIn(lista);
			return scaletabMapper.deleteByExample(example);
			
		
	}
	
	
	@Override
	public Scaletab selectByPrimaryKey(String id) {
		
			return scaletabMapper.selectByPrimaryKey(id);
		
	}

	
	@Override
	public int updateByPrimaryKeySelective(Scaletab record) {
		return scaletabMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(Scaletab record) {
		
		//添加雪花主键id
		record.setDeid(SnowflakeIdWorker.getUUID());
			
		
		return scaletabMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(Scaletab record, ScaletabExample example) {
		
		return scaletabMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(Scaletab record, ScaletabExample example) {
		
		return scaletabMapper.updateByExample(record, example);
	}

	@Override
	public List<Scaletab> selectByExample(ScaletabExample example) {
		
		return scaletabMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(ScaletabExample example) {
		
		return scaletabMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(ScaletabExample example) {
		
		return scaletabMapper.deleteByExample(example);
	}
	
	/**
	 * 修改权限状态展示或者不展示
	 * @param scaletab
	 * @return
	 */
	public int updateVisible(Scaletab scaletab) {
		return scaletabMapper.updateByPrimaryKeySelective(scaletab);
	}


}
